import { defineStore } from 'pinia'

export default defineStore('todos', {
  state: () => ({
    list: [
      {
        id: 1,
        name: '吃饭',
        done: false,
      },
      {
        id: 2,
        name: '睡觉',
        done: true,
      },
      {
        id: 3,
        name: '打豆豆',
        done: false,
      },
    ],
  }),
  actions: {
    changeDone(id) {
      const item = this.list.find((item) => item.id === id)
      item.done = !item.done
    },
  },
})
